package applet.logic;

import java.util.ArrayList;
import java.util.Hashtable;

import javax.sip.address.Address;

public class ClientManager {

	
	Hashtable<String,UserInfo> users = null;
	
	Hashtable<String,ArrayList <UserInfo>> receiving = null; 
	Hashtable<String,UserInfo> lastUserAdded = null;
	
	
	public ClientManager(){
		users = new Hashtable<String, UserInfo>();
		receiving = new Hashtable<String, ArrayList<UserInfo>>();

		lastUserAdded = new Hashtable<String, UserInfo>();
	}
	
	
	
	public void addUser(String id, Address u, String media){
		UserInfo ui = new UserInfo(id,u);
		receiving.get(media).add(users.get(id));
		lastUserAdded.put(media, ui);
		
	}

	public UserInfo getLastUser(String media){
		return lastUserAdded.get(media);
	}

	public Address getFowardingEntity(String media) {
		//To be modified introducin the algorithm for selecting the user that streams
			return getLastUser (media).getAddressheader();
	}
	
	
	
	
}
